<html>
<head><title>Nicofarre test</title></head>
<body style="margin: 0; cursor: none">
<script src="../tma.js"></script>
<script src="mv_common.js"></script>
<script>
tma.extlibs = [ 'ext/gl-matrix.js', 'ext/mv/MajVj.js' ];
tma.onload = function () {
  var width = 1920;
  var height = 1080;
  var vj = new MajVj(width, height, true);
  MajVj.loadAllPlugins().then(function () {
    var gen = [];
    gen[0] = vj.create('frame', 'nico_test');
    gen[1] = vj.create('frame', 'nicofarre',
                       { led: MajVj.frame.nicofarre.LED_FRONT_BOTH,
                         mirror: MajVj.frame.nicofarre.MIRROR_ON_RIGHT,
                         frames: ['wired', 'ab2', 'snow']});
    var fx = vj.create('effect', 'nicofarre');
    gen[0].setController(controller);
    gen[1].setController(controller);
    fx.setController(controller);
    var fbo = vj.screen().createFrameBuffer(width, height);
    vj.run(function (delta) {
      if (emulate) {
        fbo.bind();
        vj.screen().fillColor(0.0, 0.0, 0.0, 1.0);
      }
      gen[0].draw(delta);
      gen[1].draw(delta);
      if (emulate) {
        vj.screen().bind();
        vj.screen().fillColor(0.0, 0.0, 0.0, 1.0);
        fx.draw(delta, fbo.texture);
      }
      vj.screen().flush();
    });
    window.onresize = function () {
      vj.onresize();
      var ratio = vj.aspect();
      gen[0].onresize(ratio);
      gen[1].onresize(ratio);
      fx.onresize(ratio);
    };
  }, function (e) { console.log('plugin load error: ' + e); });
};
</script>
</body>
</html>
